home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 3 / Gold Medal Software - Volume 3 (Gold Medal) (1994).iso / prog / dnalib59.arj / DIALOG.BAS < prev    next >
BASIC Source File  |  1994-02-07  |  3KB  |  113 lines

  1. DECLARE SUB PopWind(Title$,TopRow%,LeftColumn%,BottomRow%,RightColumn%,Attr%,Shadow%,Border%)
  2. DECLARE SUB SaveScreen(ScreenID$,TopRow%,LeftColumn%,BottomRow%,RightColumn%,Shadow%)
  3. DECLARE SUB RestoreScreen(ScreenID$,TopRow%,LeftColumn%)
  4. DECLARE SUB CalcByte(Attr%,LowByte%,HiByte%)
  5. DECLARE SUB Clicked(Rgt%,Lft%,Row%,Col%)
  6. DECLARE SUB HideCursor()
  7. DECLARE SUB ShowCursor()
  8. DECLARE FUNCTION LeftButtonReleased%()
  9.  
  10. SUB Dialog(Choices$(),Title$,Mouse%,Cntr%,TopRow%,LeftColumn%,TxtColor%,Attr%,Shadow%,Border%) PUBLIC
  11.  
  12. CalcByte Attr%,FGround%,BGround%
  13.  
  14. IF Mouse% THEN HideCursor
  15. i% = 0: j% = 0: Maxlength% = 0: AddedRow% = 0
  16.  
  17. DO
  18.  
  19. INCR i%
  20. INCR j%                                 'first find out how many
  21.                                                                                         'strings there are and the
  22. IF LEN (Choices$(i%)) = 0 THEN          'length of the longest one
  23.   DECR i%
  24. ELSEIF LEN (Choices$(i%)) > Maxlength% THEN
  25.   Maxlength% = LEN (Choices$(i%))
  26. END IF
  27.  
  28. LOOP WHILE i% = j%
  29.  
  30. Count% = i%
  31.  
  32. INCR Maxlength%                     'add a space
  33.  
  34. SELECT CASE Cntr%
  35.     CASE 1                      'centre the window
  36.       Centre% = 1
  37.     CASE 2                      'centre the text
  38.       CentreText% = 1
  39.     CASE 3                      'centre both text and window
  40.       Centre% = 1
  41.       CentreText% = 1
  42. END SELECT
  43.  
  44. IF Centre% = 1 THEN                            'do they want it centred
  45.   LeftColumn% = 40 - ((Maxlength% + 2) / 2)
  46.   RightColumn% = LeftColumn% + (Maxlength% + 2)
  47.   TopRow% = (25 - Count%) \ 2
  48.   BottomRow% = TopRow% + (Count% + 1)
  49. ELSE
  50.   RightColumn% = LeftColumn% + (Maxlength% + 2)
  51.   BottomRow% = TopRow% + (Count% + 1)
  52. END IF
  53.  
  54. SaveScreen DLog$,TopRow%,LeftColumn%,BottomRow%,RightColumn%,Shadow%
  55.  
  56. PopWind Title$,TopRow%,LeftColumn%,BottomRow%,RightColumn%,Attr%,Shadow%,Border%
  57.  
  58. IF Mouse% THEN
  59.   Test% = LEN(Title$)
  60.   COLOR FGround%,BGround%
  61.   IF Test% THEN
  62.     IF Test% + 16 <= RightColumn% - LeftColumn% THEN
  63.       LOCATE TopRow%,LeftColumn% + 2,0
  64.       PRINT CHR$(91,254,93);
  65.     ELSE
  66.       LOCATE BottomRow%,LeftColumn% + 2,0
  67.       PRINT CHR$(91,254,93);
  68.     END IF
  69.   ELSE
  70.     LOCATE TopRow%,LeftColumn% + 2,0
  71.     PRINT CHR$(91,254,93);
  72.   END IF
  73. END IF
  74.  
  75. Row% = TopRow% + 1
  76. Col% = LeftColumn% + 1
  77.  
  78. FOR a% = 1 TO Count%
  79.   COLOR TxtColor%,BGround%
  80.   LOCATE Row%,Col%,0
  81.   IF CentreText% = 1 THEN
  82.     b% = (Maxlength% + 1) - LEN(Choices$(a%))
  83.     c% = b% \ 2
  84.     d% = b% - c%
  85.     PRINT SPACE$(c%) + Choices$(a%) + SPACE$(d%)
  86.   ELSE
  87.     PRINT SPACE$(1) + Choices$(a%) + SPACE$(Maxlength% - LEN(Choices$(a%)))
  88.   END IF
  89.   INCR Row%
  90. NEXT a%
  91.  
  92. WHILE NOT INSTAT
  93.   IF Mouse% THEN
  94.     ShowCursor
  95.     Clicked Rgt%,Lft%,MRow%,MCol%
  96.     IF LeftButtonReleased% THEN
  97.       IF MCol% = LeftColumn% + 3 THEN
  98.         IF MRow% = TopRow% OR MRow% = BottomRow% THEN
  99.           HideCursor
  100.           EXIT LOOP
  101.         END IF
  102.       ELSEIF MRow% < TopRow% OR MRow% > BottomRow% OR_
  103.         MCol% < LeftColumn% OR MCol% > RightColumn% THEN
  104.         HideCursor
  105.         EXIT LOOP
  106.       END IF
  107.     END IF
  108.   END IF
  109. WEND
  110. Ky$ = INKEY$
  111. RestoreScreen Dlog$,TopRow%,LeftColumn%
  112.  
  113. END SUB